package com.fh.alipay.model.convert;


import lombok.experimental.UtilityClass;
import com.fh.alipay.po.Merchant;
import com.fh.alipay.model.dto.MerchantDTO;
import com.fh.alipay.model.vo.MerchantVO;
import java.util.ArrayList;
import java.util.List;

/**
 * @author fh
 * @date 2022-05-02
 * @description 转换类
 */

@UtilityClass
public class MerchantConvert {


    public static Merchant toPO(MerchantDTO dto){
        Merchant result = new Merchant();
            result.setId(dto.getId());
            result.setAppId(dto.getAppId());
            result.setCreateTime(dto.getCreateTime());
            result.setUpdateTime(dto.getUpdateTime());
            result.setPrivateKey(dto.getPrivateKey());
            result.setPublicKey(dto.getPublicKey());
            result.setServerUrl(dto.getServerUrl());
            result.setDomain(dto.getDomain());
            result.setDelFlag(dto.getDelFlag());
        return result;
    }

    public static MerchantVO toVO(Merchant po){
        MerchantVO result = new MerchantVO();
                result.setId(po.getId());
                result.setAppId(po.getAppId());
                result.setCreateTime(po.getCreateTime());
                result.setUpdateTime(po.getUpdateTime());
                result.setPrivateKey(po.getPrivateKey());
                result.setPublicKey(po.getPublicKey());
                result.setServerUrl(po.getServerUrl());
                result.setDomain(po.getDomain());
                result.setDelFlag(po.getDelFlag());
            return result;
    }
    public static List<MerchantVO> toVO(List<Merchant> pos){
        if(pos == null){
            return null;
        }
        List<MerchantVO> list = new ArrayList<>();
        for(Merchant po:pos){
            list.add(toVO(po));
        }
        return list;
    }

    public static List<Merchant> toPO(List<MerchantDTO> dtos){
        if(dtos == null) {
            return null;
        }
        List<Merchant> list = new ArrayList<>();
        for(MerchantDTO dto:dtos) {
            list.add(toPO(dto));
        }
        return list;
    }


}
